package com.longk.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.longk.moduel.Article;

@Mapper
public interface ArticleMapper {
	@Insert("INSERT INTO article(articleId , content ,text, createtime, keywords, modifyTime, title, type ,userId,cover ) VALUES(#{article.articleId}, #{article.content},#{article.text},"
			+ " #{article.createTime}, #{article.keywords}, #{article.modifyTime}, #{article.title}, #{article.type},#{article.userId},#{article.cover})")
	@Options(useGeneratedKeys = true, keyProperty = "article.articleId")
	    int insertArticle(@Param("article")Article article);
	
	@Select("SELECT * from article where ds=0 limit #{start},#{size} ")
	   List<Article> selectArticle(@Param("start")int start,@Param("size")int size);
	@Select("SELECT * from article where articleid=#{id}")
	   Article selectArticleById(@Param("id")  int id);
	@Update("update  article set hitsamount=hitsamount+1 where articleid=#{id}")
	   void countArticleHits(@Param("id")  int id);
	
	@Update("update  article set keywords=#{act.keywords},modifytime=#{act.modifyTime },title=#{act.title},content=#{act.content},text=#{act.content},cover=#{act.cover}     where articleid=#{id}")
	   void update(@Param("id")  int id,@Param("act") Article art);
	

	@Update("update  article set ds=1 where articleid=#{id}")  
	   void deleteFaker(@Param("id")  int id);
}
